package com.leyou.gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xhh
 * @describe gateway路由配置
 * @date 2022/5/16
 */
@Configuration
public class GateWayConfig {
    //@Bean
    //public RouteLocator customRouteLocatorBuilder1(RouteLocatorBuilder routeLocatorBuilder){
    //    RouteLocatorBuilder.Builder builder=routeLocatorBuilder.routes();
    //    builder.route("pass1",r->r.path("/guoji").uri("http://news.baidu.com/guonji")).build();
    //    return builder.build();
    //}
    @Bean
    public RouteLocator customRouteLocatorBuilder2(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder builder=routeLocatorBuilder.routes();
        builder.route("pass2",r->r.path("/management-personnel/**").uri("lb://leyou-back-stage-management-personnel")).build();
        return builder.build();
    }
    @Bean
    public RouteLocator customRouteLocatorBuilder3(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder builder=routeLocatorBuilder.routes();
        builder.route("pass3",r->r.path("/management-mall/**").uri("lb://leyou-back-stage-management-mall")).build();
        return builder.build();
    }
    @Bean
    public RouteLocator customRouteLocatorBuilder4(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder builder=routeLocatorBuilder.routes();
        builder.route("pass4",r->r.path("/management-other/**").uri("lb://leyou-back-stage-management-other")).build();
        return builder.build();
    }
}
